/**
 * 项目版本模型
 *
 * Created by snowingsea on 2020/02/06.
 */
const mongoose = require('mongoose');
const schemaDefinition = require('./schema/project-version');
const schemaInstance = mongoose.Schema(schemaDefinition, { minimize: false });

schemaInstance.index({ projectId: 1, versionName: 1, versionType: 1 }, { unique: true });
schemaInstance.set('autoIndex', false);

const modelInstance = mongoose.model('projectVersion', schemaInstance);
mongoose.connection.on('open', () => modelInstance.syncIndexes().catch(() => { }));

/**
 * Export model definition object.
 */
module.exports = modelInstance;
